# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Peter Cai <peter at typeblog dot net>

pkgname=udp2raw
pkgver=20230206.0
_commit=e5ecd33ec4c25d499a14213a5d1dbd5d21e0dd63
pkgrel=1
pkgdesc='A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket'
url='https://github.com/wangyu-/udp2raw'
arch=('loong64' 'x86_64')
depends=('iptables')
makedepends=('git')
conflicts=('udp2raw-tunnel')
provides=('udp2raw-tunnel')
replaces=('udp2raw-tunnel')
license=('MIT')
install=udp2raw.install
source=("git+https://github.com/wangyu-/udp2raw.git#commit=$_commit"
        "udp2raw_script.sh"
        "udp2raw@.service")
sha512sums=('SKIP'
            'bd58325188f7a4d143d97ea6dfb0b8f2f86f6b82b8cb7496478fb3a9c425d42044db91bd7f554ed95443ce11bad288d48aad1f76404e3efec68ecbff8c56820f'
            'f1e2831c02163646c26601896a617e07704dc1b6324fc73f4ea576959bd33d70425472d42333ad8b7f210bd8761a83bf08db40987b016067f01590703982ae42')

build() {
  cd udp2raw
  make OPT="$CXXFLAGS $LDFLAGS" fast
}

package() {
  cd udp2raw
  install -Dm755 udp2raw -t "$pkgdir"/usr/bin/
  install -Dm644 example.conf -t "$pkgdir"/etc/udp2raw/
  install -Dm755 "$srcdir"/udp2raw_script.sh -t "$pkgdir"/usr/lib/udp2raw/
  install -Dm644 "$srcdir"/udp2raw@.service -t "$pkgdir"/usr/lib/systemd/system/
  install -Dm644 LICENSE.md -t "$pkgdir"/usr/share/licenses/$pkgname/
}
